<template>
  <CommonTablePage
      :tableInfo="tableInfo"
      :insertTableInfo="insertTableInfo"
      :tableReqUrl="tableReqUrl"
      :notUpdate="true"
      :notDelete="true"
      @onGetDeleteReqUrl="getDeleteReqUrl"
  />
</template>

<script lang="ts" setup>
import {ref, reactive, onBeforeMount, provide} from "vue";
import CommonTablePage from "@/components/common/CommonTablePage.vue";
import axios from "axios";
import {insertOptions} from "@/utils";

const tableReqUrl = ref("/api/foodOut");
const foodOptions = ref([]);

const tableInfo = ref([
  {prop: "outId", label: "出库单号"},
  {prop: "foodName", label: "食品名"},
  {prop: "outNum", label: "数量"},
  {prop: "outTime", label: "时间"},
  {prop: "adminName", label: "管理员工"},
]);

const insertTableInfo = ref([
  {
    prop: "outFoodId", label: "食品", isSelect: true, select: {key: "foodId", label: "foodName",},
    options: foodOptions.value,
  },
  {prop: "outNum", label: "数量", isNumber: true},
]);

// 删除请求url
const getDeleteReqUrl = async ({value, reFun}) => {
  reFun(`${tableReqUrl.value}/${value.outId}`);
};

const getFoodOptions = async () => {
  const {data} = await axios.get("/api/food")
  insertOptions("outFoodId", data.data, insertTableInfo.value)

}
//@ts-ignore
onBeforeMount(() => {

  getFoodOptions();

})

</script>

<style scoped>

</style>